package main.java.indi.zyj.hot100;

import main.java.indi.zyj.hot100.base.ListNode;

public class _20_reverseList {


    public ListNode reverseList(ListNode head) {

        ListNode  p, q;
        ListNode top = new ListNode(0);
        p = head;

        while (p != null) {
            q = p;
            p = p.next;
            q.next = top.next;
            top.next = q;
        }

        return top.next;

    }

}
